package com.aisino.inveli.vinda.repository;

import com.aisino.inveli.vinda.entity.Customer;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;


/**
 * @author leifeng
 * @Date 2017-11-17
 **/
public interface CustomerRepository extends JpaRepository<Customer,Integer> {

    List<Customer> findAllByCusName(String name);

    @Modifying
    @Transactional
    @Query("update Customer set isSelected = false where 1=1")
    void updateCustomer();

    Customer queryByIsSelected(Boolean flag);

    Page<Customer> findByCusNameLike(String name, Pageable pageRequest);

}
